package bite;

/**
 * Creared with IntelliJ IDEA.
 * Description:
 * User:yxd
 * Date:2022-06-28
 * Time:15:13
 */
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
class P{
    int x;
    int y;
    public P(int x,int y){
        this.x = x;
        this.y = y;
    }
}

public class Day42_2 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (input.hasNext()){
            char[][] arr= new char[10][10];
            for (int i = 0; i < 10; i++) {
                String s = input.next();
                for (int j = 0; j < 10; j++) {
                    arr[i][j] = s.charAt(j);
                }

            }
            boolean[][] bool = new boolean[10][10];//标记矩阵
            Queue<P> queue = new LinkedList<>();
            //起点
            queue.offer(new P(0,1));
            bool[0][1] = true;
            int count = 0;
            //四个方向
            int[][] d = {{1,0},{0,1},{0,-1},{-1,0}};
            //广度优先搜索
            while (!queue.isEmpty()){
                int size = queue.size();
                boolean flg = true;//判断是否到达终点
                while (size-- != 0){
                    P p = queue.poll();
                    for (int i = 0; i < d.length; i++) {
                        int nx = p.x + d[i][0];
                        int ny = p.y + d[i][1];
                        if(nx < 0 || nx >= 10
                                || ny < 0 || ny >= 10){
                            continue;
                        }
                        if(nx == 9 && ny == 8){
                            flg = false;
                            break;
                        }
                        if(!bool[nx][ny] && arr[nx][ny] != '#'){
                            //看是否走过或者到达终点
                            queue.offer(new P(nx,ny));
                            bool[nx][ny] = true;
                        }
                    }
                }
                if(flg){
                    //没有到达终点
                    count++;
                }else{
                    //到达终点
                    count++;
                    break;
                }
            }
            System.out.println(count);
        }
    }
}
